package com.example.kothin_study.dao

import kotlin.reflect.KProperty

/**
 *@author cy
 *@date 2024/8/13
 *@apiNote
 */
class Later<T>(val func: () -> T) {
    var value: Any? = null
    operator fun getValue(any: Any?, prop: KProperty<*>): T {
        if (value == null) {
            //这里别忘了将func函数类型的返回值赋值给value
            value = func()
        }
        return value as T
    }


}

fun <T> later(block: () -> T) = Later(block)